sudo useradd -r -m -s /sbin/nologin natfrp
if [[ ! -d ${HOME}/temp/downloads ]]
then
  mkdir -p ${HOME}/temp/downloads
fi
wget -O ${HOME}/temp/downloads/natfrp-service_linux_amd64.tar.zst https://nya.globalslb.net/natfrp/client/launcher-unix/3.0.9/natfrp-service_linux_amd64.tar.zst
if [[ ! -d ${HOME}/temp/downloads/natfrp ]]
then
  mkdir -p ${HOME}/temp/downloads/natfrp
fi
sudo tar -I zstd -xvf ${HOME}/temp/downloads/natfrp-service_linux_amd64.tar.zst -C /home/natfrp/
sudo chmod +x /home/natfrp/frpc /home/natfrp/natfrp-service
sudo chown natfrp:natfrp /home/natfrp/frpc /home/natfrp/natfrp-service

DIR=$( dirname "$(readlink -f  ${BASH_SOURCE[0]})" )
sudo cp ${DIR}/natfrp.service /etc/systemd/system/
sudo systemctl start natfrp.service
sleep 3
sudo systemctl stop natfrp.service
sudo ls -ls /home/natfrp/.config/natfrp-service/config.json
if [[ $? -eq 1 ]]
then
  echo "start error , not found configuration"
  exit
fi
manager_pass_word=$(sudo /home/natfrp/natfrp-service remote-kdf QQ025025)
echo "pass:"$manager_pass_word
sudo python3 ${DIR}/update.py $manager_pass_word "y1dqur5fcjnv1rovmes84ewsz6puyz85"
sudo systemctl enable --now natfrp.service
sudo systemctl status natfrp.service
